package  com.pcbly.web.business.crm;

/**
* @author carl.song
* Copyright (c) 2010 Lightsoft, International.
* All rights reserved.
*
*/

import java.util.HashMap;
import java.util.List;

import com.pcbly.web.persistence.crm.ChtjDescDao;
import com.pcbly.web.persistence.table.ColumnDao;
import com.pcbly.web.bean.crm.ChtjDescBean;
import com.pcbly.web.bean.table.ColumnBean;
import com.pcbly.web.business.BaseServiceImp;
import com.pcbly.web.components.hibernate.support.Page;
import com.pcbly.web.components.form.AbstractAnalyseCommonDataExt;
import com.pcbly.web.components.form.AnalyseCommonDataExtCreate;
import com.pcbly.web.components.form.AnalyseCommonDataExtEdit;
import com.pcbly.web.components.form.AnalyseCommonDataExtView;

 
public class ChtjDescServiceImp extends BaseServiceImp<ChtjDescBean> implements ChtjDescService {
	 public ChtjDescServiceImp() {
		super();
		// TODO Auto-generated constructor stub
	}
	private ChtjDescDao chtjDescDao;
	
	private ColumnDao columnDao;

	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	
	public void setChtjDescDao(ChtjDescDao chtjDescDao) {
		this.chtjDescDao = chtjDescDao;
	}
	
	@Override
	public ChtjDescBean getChtjDescBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return chtjDescDao.get(ChtjDescBean.class,id);
	}
	
	@Override
	public void removeChtjDescBeanById(String id) throws Exception{
		chtjDescDao.removeChtjDescBeanById(id);
	}
	
	@Override
	public void removeChtjDescBeanByIds(String ids) throws Exception{
		chtjDescDao.removeChtjDescBeanByIds(ids);
	}
	
	
	@Override
	public ChtjDescBean saveChtjDescBean(ChtjDescBean crm) throws Exception{
		return chtjDescDao.saveChtjDescBean(crm);
	}
	
	@Override
	public ChtjDescBean updateChtjDescBean(ChtjDescBean crm) throws Exception{
		chtjDescDao.saveObject( crm);
		return crm;
	}
	public Page<ChtjDescBean>  findChtjDescBeanByCond(ChtjDescBean bean,
			Page<ChtjDescBean> page, String orderByName, boolean asc)
			throws Exception{
		return chtjDescDao.findChtjDescBeanByCond(
				bean, page, orderByName, asc);
	}
	
	@Override
	public String findChtjDescBeanExtCreate(String tableName) throws Exception {
		// TODO Auto-generated method stub
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtCreate();
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findChtjDescBeanExtEdit(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = chtjDescDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtEdit();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findChtjDescBeanExtView(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = chtjDescDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtView();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public void saveChtjDescBeanExt(String sql) throws Exception {
		// TODO Auto-generated method stub
		chtjDescDao.saveCommnonDataBeanExt(sql);
	}

	@Override
	public boolean getHasChtjDescBeanExtData(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		return chtjDescDao.getHasCommnonDataBeanExt(tableName, id);
	}
}
